package DesignPattern.responsibility;

/**
 * @Author self
 * @Date 2025/7/10 20:21
 * @Describe
 */
// 具体处理器B
public class ConcreteHandlerB extends Handler {
    @Override
    public void handle(Request request) {
        if (canHandle(request)) {
            System.out.println("ConcreteHandlerB handled the request.");
        } else {
            super.handle(request); // 如果不能处理，则传递给下一个处理器
        }
    }

    private boolean canHandle(Request request) {
        // 判断是否能处理此请求的逻辑
        return "typeB".equals(request.getType());
    }
}